{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "eb386615",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#1.cookies实现登录，获取完整数据\" data-toc-modified-id=\"1.cookies实现登录，获取完整数据-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>1.cookies实现登录，获取完整数据</a></span></li><li><span><a href=\"#2.尝试使用数据分析进行数据交互式可视化\" data-toc-modified-id=\"2.尝试使用数据分析进行数据交互式可视化-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>2.尝试使用数据分析进行数据交互式可视化</a></span></li></ul></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddbbbfb7",
   "metadata": {},
   "source": [
    "## 1.cookies实现登录，获取完整数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2cb0dc30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'__uuid=1685531397905.58; __gc_id=89fc06a08b3f46fdbae0b34a1163f247; need_bind_tel=false; new_user=false; c_flag=f7c96e82683edc3a46415fb94deacfbb; imId=b5e1273d5cb093f45bf0dcfaa7d2ce41; imId_0=b5e1273d5cb093f45bf0dcfaa7d2ce41; imClientId=b5e1273d5cb093f47e9ff1932c4dba7b; imClientId_0=b5e1273d5cb093f47e9ff1932c4dba7b; _ga=GA1.1.1638183886.1697023059; __tlog=1698838681842.60%7C00000000%7C00000000%7Cs_00_pz0%7Cs_00_pz0; XSRF-TOKEN=trZqhSyuQ2KeyAGEhERRCw; UniqueKey=5db59b88b7623a967ecd4408bb1e9b04; liepin_login_valid=0; lt_auth=s%2BxePCAByw%2Bs4nOIgWUIsv5N29z6U2udoXRbjUxU0dC7CPPl4P%2FmQAOHqrcG%2FCoIq0snd64zMLb3PeD9wXRL7UMV%2FVGnlZ6utf6k1X8eTuxgHuyflMXuqsjQQJgirXo6ykpgn2si0HU%3D; access_system=C; inited_user=a875a3b7ef09339304aa8ceeb8aec5ed; user_roles=0; user_photo=5f8fa3a9dfb13a7dee343d4808u.png; user_name=%E6%9D%8E%E9%94%A6%E9%B9%8F; Hm_lvt_a2647413544f5a04f00da7eee0d5e200=1697023048,1698838718; hpo_role-sec_project=sec_project_liepin; hpo_sec_tenant=0; acw_tc=2760828416988387184312737e53944cf3bbbe29242bf2a108d73aaff92299; imApp_0=1; __session_seq=3; __uv_seq=3; __tlg_event_seq=5; Hm_lpvt_a2647413544f5a04f00da7eee0d5e200=1698838726; fe_im_socketSequence_new_0=2_2_2; fe_im_opened_pages=; fe_im_connectJson_0=%7B%220_5db59b88b7623a967ecd4408bb1e9b04%22%3A%7B%22socketConnect%22%3A%222%22%2C%22connectDomain%22%3A%22liepin.com%22%7D%7D;'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 建立登陆cookie\n",
    "cookie = \"__uuid=1685531397905.58; __gc_id=89fc06a08b3f46fdbae0b34a1163f247; need_bind_tel=false; new_user=false; c_flag=f7c96e82683edc3a46415fb94deacfbb; imId=b5e1273d5cb093f45bf0dcfaa7d2ce41; imId_0=b5e1273d5cb093f45bf0dcfaa7d2ce41; imClientId=b5e1273d5cb093f47e9ff1932c4dba7b; imClientId_0=b5e1273d5cb093f47e9ff1932c4dba7b; _ga=GA1.1.1638183886.1697023059; __tlog=1698838681842.60%7C00000000%7C00000000%7Cs_00_pz0%7Cs_00_pz0; XSRF-TOKEN=trZqhSyuQ2KeyAGEhERRCw; UniqueKey=5db59b88b7623a967ecd4408bb1e9b04; liepin_login_valid=0; lt_auth=s%2BxePCAByw%2Bs4nOIgWUIsv5N29z6U2udoXRbjUxU0dC7CPPl4P%2FmQAOHqrcG%2FCoIq0snd64zMLb3PeD9wXRL7UMV%2FVGnlZ6utf6k1X8eTuxgHuyflMXuqsjQQJgirXo6ykpgn2si0HU%3D; access_system=C; inited_user=a875a3b7ef09339304aa8ceeb8aec5ed; user_roles=0; user_photo=5f8fa3a9dfb13a7dee343d4808u.png; user_name=%E6%9D%8E%E9%94%A6%E9%B9%8F; Hm_lvt_a2647413544f5a04f00da7eee0d5e200=1697023048,1698838718; hpo_role-sec_project=sec_project_liepin; hpo_sec_tenant=0; acw_tc=2760828416988387184312737e53944cf3bbbe29242bf2a108d73aaff92299; imApp_0=1; __session_seq=3; __uv_seq=3; __tlg_event_seq=5; Hm_lpvt_a2647413544f5a04f00da7eee0d5e200=1698838726; fe_im_socketSequence_new_0=2_2_2; fe_im_opened_pages=; fe_im_connectJson_0=%7B%220_5db59b88b7623a967ecd4408bb1e9b04%22%3A%7B%22socketConnect%22%3A%222%22%2C%22connectDomain%22%3A%22liepin.com%22%7D%7D;\"\n",
    "cookie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "57dbb571",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'liepindata'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [3]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mcrawl_liepin\u001b[39;00m\n\u001b[0;32m      3\u001b[0m 产品经理_深圳_results \u001b[38;5;241m=\u001b[39m crawl_liepin\u001b[38;5;241m.\u001b[39mcrawl(城市\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m深圳\u001b[39m\u001b[38;5;124m\"\u001b[39m,关键词\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m产品经理\u001b[39m\u001b[38;5;124m\"\u001b[39m,工作经验\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m,登录cookie\u001b[38;5;241m=\u001b[39mcookie)\n",
      "File \u001b[1;32mD:\\Web-data-mining\\Week09\\crawl_liepin.py:1\u001b[0m, in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mliepindata\u001b[39;00m\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mjson\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mrequests_html\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HTMLSession\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'liepindata'"
     ]
    }
   ],
   "source": [
    "import crawl_liepin\n",
    "\n",
    "产品经理_深圳_results = crawl_liepin.crawl(城市=\"深圳\",关键词=\"产品经理\",工作经验='',登录cookie=cookie)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b96ff44b",
   "metadata": {},
   "source": [
    "## 2.尝试使用数据分析进行数据交互式可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "18452dfc",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name '产品经理_深圳_results' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [4]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43m产品经理_深圳_results\u001b[49m\u001b[38;5;241m.\u001b[39mto_html\n",
      "\u001b[1;31mNameError\u001b[0m: name '产品经理_深圳_results' is not defined"
     ]
    }
   ],
   "source": [
    "产品经理_深圳_results.to_html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7270d063",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name '产品经理_深圳_results' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [5]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m series_dq \u001b[38;5;241m=\u001b[39m \u001b[43m产品经理_深圳_results\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mjob.dq\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mvalue_counts()\n\u001b[0;32m      2\u001b[0m series_dq\n",
      "\u001b[1;31mNameError\u001b[0m: name '产品经理_深圳_results' is not defined"
     ]
    }
   ],
   "source": [
    "series_dq = 产品经理_深圳_results['job.dq'].value_counts()\n",
    "series_dq"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "71d4987d",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'series_dq' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [6]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m dq_name\u001b[38;5;241m=\u001b[39m [i \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[43mseries_dq\u001b[49m\u001b[38;5;241m.\u001b[39mindex \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m i]\n\u001b[0;32m      2\u001b[0m dq_name\n",
      "\u001b[1;31mNameError\u001b[0m: name 'series_dq' is not defined"
     ]
    }
   ],
   "source": [
    "dq_name= [i for i in series_dq.index if '-' in i]\n",
    "dq_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "e4797ef0",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'series_dq' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [7]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mseries_dq\u001b[49m[dq_name]\u001b[38;5;241m.\u001b[39mvalues\n",
      "\u001b[1;31mNameError\u001b[0m: name 'series_dq' is not defined"
     ]
    }
   ],
   "source": [
    "series_dq[dq_name].values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2f70399f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pyecharts in c:\\anaconda\\lib\\site-packages (2.0.3)\n",
      "Requirement already satisfied: prettytable in c:\\anaconda\\lib\\site-packages (from pyecharts) (3.7.0)\n",
      "Requirement already satisfied: jinja2 in c:\\anaconda\\lib\\site-packages (from pyecharts) (2.11.3)\n",
      "Requirement already satisfied: simplejson in c:\\anaconda\\lib\\site-packages (from pyecharts) (3.19.1)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in c:\\anaconda\\lib\\site-packages (from jinja2->pyecharts) (2.0.1)\n",
      "Requirement already satisfied: wcwidth in c:\\anaconda\\lib\\site-packages (from prettytable->pyecharts) (0.2.5)\n"
     ]
    }
   ],
   "source": [
    "!pip install pyecharts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d6e20324",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map\n",
    "from pyecharts.faker import Faker"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a66c6348",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'dq_name' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [10]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m [i\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m-\u001b[39m\u001b[38;5;124m'\u001b[39m)[\u001b[38;5;241m1\u001b[39m] \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m \u001b[43mdq_name\u001b[49m]\n",
      "\u001b[1;31mNameError\u001b[0m: name 'dq_name' is not defined"
     ]
    }
   ],
   "source": [
    "[i.split('-')[1] for i in dq_name]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "978cb508",
   "metadata": {},
   "outputs": [],
   "source": [
    "series_dq[dq_name].values.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "58961b0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "c = (\n",
    "    Map()\n",
    "    .add(\"产品经理地区分布\", [list(z) for z in zip([i.split('-')[1] for i in dq_name],series_dq[dq_name].values.tolist())], \"深圳\")\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Map-深圳-产品经理\"), visualmap_opts=opts.VisualMapOpts()\n",
    "    )\n",
    "    \n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d532625",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47260fe2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
